package com.sskj.fca.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.sskj.fca.R;
import com.sskj.fca.bean.MainMenuBean;

import java.util.List;

/**
 * Created by Q-Kang on 2019/1/14.
 */

public class QiangjinSpinnerAdapter extends BaseAdapter {
    private List<MainMenuBean> datas;
    private Context context;

    public QiangjinSpinnerAdapter(List<MainMenuBean> datas, Context context) {
        this.datas = datas;
        this.context = context;
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int i) {
        return datas.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        if (view == null) {
            holder = new ViewHolder();
            view = LayoutInflater.from(context).inflate(R.layout.app_recy_item_main_menu, viewGroup, false);
            holder.imageView = view.findViewById(R.id.ivTitle);
            holder.textView = view.findViewById(R.id.tvTitle);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        holder.imageView.setImageResource(datas.get(i).getRes());
        holder.textView.setText(datas.get(i).getContent());
        return view;
    }

    class ViewHolder {
        ImageView imageView;
        TextView textView;
    }


}
